<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>metting</title>

    <link rel="stylesheet" href="layui/css/layui.css">
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
    <script src="layui/layui.js"></script>
</head>
<body>
    <table class="layui-table" lay-data="{width: 1000, height:330, url:'/getOrderList', page:true, id:'idTest'}" lay-filter="demo">
        <thead>
        <tr>
            <th lay-data="{type:'checkbox', fixed: 'left'}"></th>
            <th lay-data="{field:'no'}">no</th>
            <th lay-data="{field:'name'}">姓名</th>
            <th lay-data="{field:'mobile'}">手机号</th>
            <th lay-data="{fixed: 'right', align:'center', toolbar: '#barDemo'}"></th>
        </tr>
        </thead>
    </table>

    <script type="text/html" id="barDemo">
        <a href="javascript:;" class="layui-btn layui-btn-sm upward" id="up" name="up">上移</a>
        <a href="javascript:;" class="layui-btn layui-btn-sm down" id="down" name="down">下移</a>
        <a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-danger" id="delete">删除</a>
    </script>

    <script>

        //上移
        $(document).on("click",".upward",function(){
            var $up = $(".upward")
            $(this).each(function(){
                var $tr = $(this).parents("tr");
                if($tr.index() != 0){
                    $tr.prev().before($tr);
                }
            });
            console.log(layui.table.cache["idTest"])
            console.log($up)
        });
        //下移
        $(document).on("click",".down",function(){
            var $down = $(".down")
            var len = $down.length;
            $(this).each(function(){
                var $tr = $(this).parents("tr");
                if ($tr.index() != len - 1) {
                    $tr.next().after($tr);
                }
            });
        });

        layui.use('table', function(){
            var table = layui.table;
            //监听表格复选框选择
            table.on('checkbox(demo)', function(obj){
                console.log(obj)
            });

            $('.demoTable .layui-btn').on('click', function(){
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
        });
    </script>
</body>

</html>